package top.zerozoo.learn.grade.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 禁止直接访问jsp文件的过滤器
 * jsp应通过servlet转发
 */
@WebFilter(value = "*.jsp")
public class JspFilter implements Filter {
    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException {
        HttpServletResponse httpResponse = (HttpServletResponse) response;
        httpResponse.sendError(HttpServletResponse.SC_NOT_FOUND);
    }
    @Override
    public void init(FilterConfig config) throws ServletException {

    }
    @Override
    public void destroy() {

    }
}
